/**********************************
 * @Author: Your Name
 * @LastEditor: Your Name
 * @LastEditTime: 2025-11-07
 * Copyright © 2025 Your Name
 **********************************/

import { request } from '@/utils/http'

// 项目管理相关API
export default {
  // 获取项目列表
  read: (params = {}) => {
    return request({
      url: '/pms/project',
      method: 'GET',
      params,
    })
  },

  // 创建项目
  create: (data) => {
    return request({
      url: '/pms/project',
      method: 'POST',
      data,
    })
  },

  // 更新项目
  update: (data) => {
    return request({
      url: '/pms/project',
      method: 'PUT',
      data,
    })
  },

  // 删除项目
  delete: (id) => {
    return request({
      url: `/pms/project/${id}`,
      method: 'DELETE',
    })
  },

  // 根据ID获取项目
  get: (id) => {
    return request({
      url: `/pms/project/${id}`,
      method: 'GET',
    })
  },

  // 获取项目分类列表（分页）
  pageQueryCategories: (params = {}) => {
    return request({
      url: '/pms/project-category',
      method: 'GET',
      params,
    })
  },

  // 获取所有项目分类（非分页）
  getProjectCategories: () => {
    return request({
      url: '/pms/project-category/list-all',
      method: 'GET',
    })
  },

  // 创建项目分类
  createCategory: (data) => {
    return request({
      url: '/pms/project-category',
      method: 'POST',
      data,
    })
  },

  // 更新项目分类
  updateCategory: (data) => {
    return request({
      url: '/pms/project-category',
      method: 'PUT',
      data,
    })
  },

  // 删除项目分类
  deleteCategory: (id) => {
    return request({
      url: `/pms/project-category/${id}`,
      method: 'DELETE',
    })
  },

  // 获取项目状态选项
  getProjectStatusOptions: () => {
    // 这个是固定选项，前端可以定义，也可以通过API从后端获取
    return Promise.resolve({
      code: 0,
      message: 'success',
      data: [
        { name: '规划中', value: 'PLANNING' },
        { name: '进行中', value: 'IN_PROGRESS' },
        { name: '已完成', value: 'COMPLETED' },
        { name: '已暂停', value: 'PAUSED' },
        { name: '已取消', value: 'CANCELLED' },
      ],
    })
  },

  // 获取用户列表
  getUsers: (params = {}) => {
    return request({
      url: '/pms/project/users',
      method: 'GET',
      params,
    })
  },
}
